﻿<%@ page 
language="java" 
import="java.util.*" 
import="com.csd.pojo.*" 
import="com.csd.helper.*"
import="com.csd.vo.*"
pageEncoding="UTF-8"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<ResearchField> researchFieldList = (List<ResearchField>)request.getAttribute("listOfResearchField");
List<UserVO> teacherList = (List<UserVO>)request.getAttribute("listOfTeacher");
String projectTypeID = (String)request.getAttribute("projectTypeID");
if(researchFieldList == null || teacherList ==null)
{
	
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ taglib prefix="s" uri="/struts-tags"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>项目申请</title>
<link href="<%=path %>/student/css/student_right.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript" src="<%=path %>/student/js/check.js"></script>
 <script type="text/javascript">    
	function checkContent()
	{
		var flag=true;
		var projname = document.getElementsByName('newProject.projectname')[0];
		var projdescrip = document.getElementsByName('newProject.introduction')[0];
		var fileupload = document.getElementById('fileField');
		if (projname.value == ""){
			flag=false;
			checkNotNull(projname);
			}

		if (projdescrip.value == "请认真填写项目的技术路线，项目创新点，项目难点等情况..."){
			flag=false;
			projdescrip.style.color="red";
			}
			
		if(fileupload.value==""){
		    flag=false;
		    checkNotNull(fileupload);
		    }
        return flag;
	}
</script>
<script type="text/javascript">
function goto(url,delay)
{
setTimeout("window.location='"+url+"'",delay);
}
</script>
<script type="text/javascript">
function fileFormat(){
	var filepath=document.getElementById('fileField').value;
	filepath = filepath.substring(filepath.lastIndexOf('.')+1,filepath.length);
	if(filepath != 'doc' && filepath != 'docx' && filepath!='pdf'){
	alert("只能上传.doc或.docx或.pdf格式的文档");
	document.getElementById("fileField").outerHTML=document.getElementById("fileField").outerHTML.replace(/value=\w/g,'');
	}
}
</script>
<script type="text/javascript">
function cls(){
var area=document.getElementsByName('newProject.introduction')
if( area[0].value== '请认真填写项目的技术路线，项目创新点，项目难点等情况...'){area[0].value =""; area[0].style.color = '#000000'; }
}
</script>
<script type="text/javascript">

function hint(){
var area=document.getElementsByName('newProject.introduction')
if(area[0].value == ""){area[0].style.color = '#ACA899'; area[0].value = '请认真填写项目的技术路线，项目创新点，项目难点等情况...'; }
}
function hintForLength(num){
	var introduction = document.getElementsByName('newProject.introduction');
	if(introduction[0].value.length >= num){
	document.getElementById('error1').innerHTML = "最多输入"+num+"字介绍";
	}else{
	document.getElementById('error1').innerHTML = "";
	}
	}
</script>

</head>



<body onload="hint()">
    <div class="main">
    <h1>项目申请</h1>
    <hr />
    <div id="error" style="text-align:center; color:#FF0000;"></div>
    <form id="scrForm" action="projectCreate.action" method="post" enctype="multipart/form-data" onsubmit="return checkContent()">
    <input type="hidden" name="newProject.projectType.id" value="<%=projectTypeID %>"/>
    <table cellpadding="5px" cellspacing="5px">
      <tr> 
            <td class="form_strong" width="200px">项目名称：</td> 
            <td>
                <input name="newProject.projectname" type="text" id="textfield" maxlength="20" onblur="javascript:checkNotNull(this);" /> 
            </td> 
      </tr>
      <tr>
            <td class="form_strong">周期：</td> 
            <td>
                <select name="newProject.cycle" id="select"> 
                  <option value="<%=Cycle.halfYear%>">半年</option> 
                  <option value="<%=Cycle.wholeYear%>">一年</option> 
                </select>  
            </td> 
      </tr> 
      <tr> 
            <td class="form_strong">研究领域：</td> 
            <td>
                <select name="newProject.researchField.id" id="select2"> 
                <%for(ResearchField researchField:researchFieldList){%>
                    <option value="<%=researchField.getId() %>" > <%=researchField.getName()%></option> 
                   <%} %>
                </select>
            </td> 
      </tr>
      <tr>
        	<td class="form_strong">指导老师：</td> 
        	<td>	
                <select name="newProject.teacher.id" id="select3"> 
                 <%for(UserVO teacher:teacherList){ %>
                  <option value="<%=teacher.getUserID()%>"><%=teacher.getName()%></option> 
                <%} %>
                </select>
          	</td> 
      </tr> 
      <tr> 
            <td class="form_strong">项目描述：</td> 
            <td>
         		<textarea name="newProject.introduction" id="textarea" cols="45" rows="5" onblur="checkNotNull(this);hint();" onfocus="cls();checkNotNull(this);" onkeydown="javascript:checkTextAreaLength(this, 0, 200);hintForLength(200);"></textarea>
              </td>
           <tr> <td class="form_strong" width="200px"></td> 
            <td>   <span id="error1" style="text-align:center; color:#FF0000;"></span>
                </td></tr>
      </tr> 
      
      <tr> 
            <td class="form_strong">上传申请书：</td> 
            <td>
            <input type="file" name="upload" id="fileField" onchange="javascript:checkNotNull(this);fileFormat();"/>
               <br/><span id="filesize">&nbsp;文件大小请不要超过5MB<br/>上传文件格式：doc,docx,pdf</span>
               <span id="alarm" style="color:#F33; display:none;"><br />文件过大了!</span>
            </td> 
      </tr> 
      <tr> 
        	<td colspan="2" align="center" height="30px" valign="bottom">
            	<input type="submit" value=" 提交 "/> 
                &nbsp; &nbsp; &nbsp;  
            	<input type="button" value="取消" onclick="goto('<%=path %>/projectTypeList.action',0)"/ >         
        	</td> 
      </tr> 
    </table> 
    </form>
    </div>
</body>
</html>

